#!/bin/bash
port=`netstat -tnlp|grep vsftp|awk '{print $4}'|awk -F':' '{print $4}'`
pid=`ps -aux|grep [v]sftpd|awk 'NR==1{print $2}'`
if [ $port -ne 0 ]&>/dev/null
then
    echo "ftp已启动"
    echo "监听的地址："
    echo "ftp监听的端口:$port"
    echo "ftp进程PID:$pid"
else
    echo "ftp未启动"
    read -p "Do you want to start vsftpd?(yes|no)" switch
    case $switch in
    yes|y|Y|YES)
    systemctl start vsftpd
    echo "vsftpd启动完成"
    ;;
    no|n|N|NO)
    echo "退出" && exit
    ;;
    esac
fi

